function [] = main_2(img)
    % 不同的滤波器对加了不同噪声的图像处理后的区别

    function [output]=averagefilt2(img, sz)
        output = imfilter(img, fspecial('average', sz));
    end

    imgWithNoise1 = imnoise(img, 'salt & pepper', 0.05');
    imgWithNoise2 = imnoise(img, 'gaussian', 0.05');

    imgList = {
        imgWithNoise1
        averagefilt2(imgWithNoise1, [3 3])
        medfilt2(imgWithNoise1, [3 3])
        wiener2(imgWithNoise1, [3 3])
        imgWithNoise2
        averagefilt2(imgWithNoise2, [3 3])
        medfilt2(imgWithNoise2, [3 3])
        wiener2(imgWithNoise2, [3 3])
    };
    titleList = {
        '椒盐噪声图像'
        '均值滤波'
        '中值滤波'
        '维纳滤波'        
        '高斯噪声图像'
        '均值滤波'
        '中值滤波'
        '维纳滤波'
    };
    for i = 1: 8
        subplot(2, 4, i);
        imshow(imgList{i});
        title(titleList{i});
    end
end